<template>
  <div class="app-container">
    <div class="mapDiv" v-loading="loading">
      <!--地图-->
      <IndexMap v-if="completeRefreshData==true"
                :allRadioIndexData="allRadioIndexData"
                :allListData="allListData"
                :typeCodeDataList="typeCodeDataList"
                :resetClearAllBool="resetClearAllBool"
                :dataTypeInfoArray="dataTypeInfoArray"
                @getDetailDataById="getDetailDataById"
                @getLegendHtml="getLegendHtml"
                @getAllTempLayersSetList="getAllTempLayersSetList"
      ></IndexMap>
    </div>
    <div id="indexMap-mapDiv" class="ol-popup">
      <div class="select">
        <div class="selectData"><span>选择数据</span><el-icon style="cursor:pointer;" :size="23" @click="hideTabBoxDiv"><Expand /></el-icon></div>
        <!-- <div style="position: absolute;top: 0px;left: 160px;width: 300px;">
          <el-button type="primary" @click="uploadSlopeTifAspectTif('dxdmpd')">导入坡度</el-button>
          <el-button type="primary" @click="uploadSlopeTifAspectTif('dxdmpx')">导入坡向</el-button>
          <el-select v-model="addDataType" placeholder="请选择数据类别" clearable @change="chooseAddDataType">
            <el-option key="dxdmpd" label="坡度" value="坡度"></el-option>
            <el-option key="dxdmpx" label="坡向" value="坡向"></el-option>
          </el-select>
          <el-button type="primary" @click="handleAdd" style="position:absolute;">添加数据</el-button>
        </div> -->
      </div>
      <!--选择数据收起div-->
      <div class="box-hide-div" v-if="boxshow==false">
        <span class="box-hide-div-label-span">当前选择：</span>
        <span class="box-hide-div-text-span" v-if="queryParams.dataRangeText!='' || queryParams.dataLayerText!=''">
          {{ queryParams.dataRangeText }}，{{ queryParams.dataLayerText }}
        </span>
      </div>
      <!--选择数据展开div-->
      <div class="box" :class="versionCodeDivShow?'box-max':'box-min'" v-if="boxshow==true">
        <!--选择数据内容div-->
        <div style="position:absolute;top:0px;left:0px;bottom:40px;width:400px;">
          <!--tab标签页-->
          <div class="tab-div">
            <div class="tab-button" :class="activeName=='版本范围'?'tab-active':'tab-no'" @click="showDataRangeTab">
              版本范围
            </div>
            <div class="tab-button" :class="activeName=='数据图层'?'tab-active':'tab-no'" @click="showDataLayerTab">
              数据图层
            </div>
          </div>
          <!--tab内容div-->
          <div class="tab-content-all-div">
            <!--版本范围tab内容-->
            <div v-if="activeName=='版本范围'" class="tab-content">
              <span class="tab-span" @click="hideTabBoxDiv">收起</span>
              <div style="position:absolute;top:40px;left:20px;right:20px;bottom:0px;">
                <el-radio-group v-model="queryParams.dataRangeCountry" @change="changeRadio" style="margin-bottom: 20px;">
                  <el-radio label="1">国家级数据</el-radio>
                  <el-radio label="2">省级数据</el-radio>
                </el-radio-group>
                <el-form :model="queryParams" ref="queryRef" label-width="50px" :rules="rules">
                  <el-row>
                    <el-col>
                      <el-form-item label="省" prop="dataRangeProvince">
                        <el-select v-model="queryParams.dataRangeProvince" placeholder="请选择" @change="chooseProvince" clearable
                                   :disabled="disabled1==true">
                          <el-option key="全国" label="全国" value="全国" v-if="queryParams.dataRangeCountry == '1'"></el-option>
                          <el-option v-for="item in provinceData" :key="item.id" :label="item.name" :value="item.name"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col>
                      <el-form-item label="市" prop="dataRangeCity">
                        <el-select v-model="queryParams.dataRangeCity" placeholder="请选择" @change="chooseCity" clearable
                                   :disabled="queryParams.dataRangeProvince=='全国'">
                          <el-option key="全部" label="全部" value="全部" v-if="cityData&&cityData.length>0"></el-option>
                          <el-option v-for="item in cityData" :key="item.id" :label="item.name" :value="item.name"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col>
                      <el-form-item label="区/县" prop="dataRangeArea">
                        <el-select v-model="queryParams.dataRangeArea" placeholder="请选择" @change="chooseArea" clearable
                                   :disabled="queryParams.dataRangeProvince=='全国' || queryParams.dataRangeCity=='全部'">
                          <el-option key="全部" label="全部" value="全部" v-if="areaData&&areaData.length>0"></el-option>
                          <el-option v-for="item in areaData" :key="item.id" :label="item.name" :value="item.name"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-form>
                <div style="float: right;margin-right: 50px;">
                  <el-button type="primary" @click="submitSelect">确定</el-button>
                  <el-button @click="resetSelect">重置</el-button>
                </div>
              </div>
            </div>
            <!--数据图层tab内容-->
            <div v-if="activeName=='数据图层'" class="tab-content">
              <!--版本范围当前选择div-->
              <div style="width:100%;height:80px;background:rgb(230 242 253);overflow: hidden;">
                <span class="tab-span" @click="showDataRangeTab">展开</span>
                <span class="tab-layercollapse-allHide-label-span">当前选择：</span><br/>
                <span class="tab-layercollapse-allHide-text-span">
                  {{ queryParams.dataRangeText }}
                </span>
              </div>
              <!--数据图层当前选择div（展开）-->
              <div v-if="collapseData.showHideBool==true" class="tab-layercollapse-allShow">
                <div class="tab-layercollapse-allShow-head">
                  <span class="tab-span" @click="hideCollapseDiv">收起</span>
                  <span class="tab-span" @click="resetCollapseDiv" >重置</span>
                </div>
                <!--数据图层类型选择div-->
                <div class="tab-layercollapse-div">
                  <el-radio-group v-model="activeRadioLabel" @change="radioChange" style="display: block;">
                    <el-collapse v-model="activeNames" @change="handleChange">
                      <el-collapse-item v-for="item in collapseLayerData" :title="item.label" :name="item.value" class="tab-layercollapse-header">
                        <div v-for="child in item.children" class="tab-collapse-radioDiv">
<!--                          <el-radio :label="child.radioLabel">{{child.name}}</el-radio>-->
                          <el-radio :label="child.radioLabel">
                            <template v-if="child.name=='地形地貌坡度'">坡度</template>
                            <template v-else-if="child.name=='地形地貌坡向'">坡向</template>
                            <template v-else>{{child.name}}</template>
                          </el-radio>
                        </div>
                      </el-collapse-item>
                    </el-collapse>
                  </el-radio-group>
                </div>
              </div>
              <!--数据图层当前选择div（收起）-->
              <div v-if="collapseData.showHideBool==false" class="tab-layercollapse-allHide">
                <span class="tab-span" @click="collapseData.showHideBool=true">展开</span>
                <span class="tab-layercollapse-allHide-label-span">当前选择：</span><br/>
                <span class="tab-layercollapse-allHide-text-span">
                  {{ queryParams.dataLayerText }}
                </span>
              </div>
              <!--重置div-->
              <div v-if="collapseData.showHideBool==false">
                <span style="float: right;margin:10px;color: #107ce5;cursor: pointer;font-size: 14px;" @click="resetAllCollapseDiv" >重置</span>
              </div>
            </div>
          </div>
        </div>
        <!--底部收起按钮div-->
        <div class="foot-div" @click="hideTabBoxDiv">
          <svg-icon style="width:100%;height:100%;" class-name="arrow_drop_up-icon" icon-class="arrow_drop_up" />
        </div>
        <!--选择数据版本号div-->
        <div class="tab-select-versionCode-div" v-if="versionCodeDivShow">
          <el-input v-model="queryParams.dataTypeCodeSearchText" @change="querySysDataVersion" size="large" placeholder="请输入版本号" prefix-icon="Search"/>
          <p style="height:20px;color:black;font-weight: bold;">{{collapseData.layerName}}</p>
          <div class="tab-table-div">
            <el-table :data="versionCodeTableData" ref="versionCodeTable" @row-click="clickRow"
                      @select="handleSelectionChange" stripe style="width: 100%">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="versionCode" label="版本号" width="190" />
              <el-table-column prop="uploadTime" label="上传时间" width="120" />
              <el-table-column align="right" width="50">
                <template #header></template>
                <template #default="scope">
                  <!--版本信息-->
                  <el-popover placement="right" :width="210" trigger="hover">
                    <template #reference>
                      <div style="height: 20px;">
                        <svg-icon style="width:100%;height:100%;" class-name="three_point_new-icon" icon-class="three_point_new" />
                      </div>
                    </template>
                    <template #default>
                      <p style="height: 20px;line-height: 20px;margin: 0px;font-weight: bold;">版本信息</p>
                      <el-divider style="margin:10px 0;" />
                      <p style="font-weight: bold;">版本说明：</p>
                      <p style="max-height: 200px;overflow: auto;">{{ scope.row.versionDesc }}</p>
                      <p style="font-weight: bold;">数据说明：</p>
                      <p style="max-height: 200px;overflow: auto;">{{ scope.row.dataDesc }}</p>
                      <p v-if="activeRadioLabel=='dxdmpd' || activeRadioLabel=='dxdmpx'">
                        <span style="font-weight: bold;">上传人：</span>{{scope.row.uploadUserName}}
                      </p>
                      <p v-else><span style="font-weight: bold;">上传人：</span>{{scope.row.uploadUser}}</p>
                    </template>
                  </el-popover>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!--操作-->
          <div class="table-button-div" v-if="activeRadioLabel=='dxdmpd' || activeRadioLabel=='dxdmpx'">
            <el-button type="primary" @click="handleMore">更多信息</el-button>
            <el-button type="primary" @click="openDetail">元数据管理</el-button>
            <el-button type="primary" @click="handleDelete">删除</el-button>
          </div>
        </div>
      </div>
      <!--更多信息-->
      <el-dialog v-model="openMore" width="800px" title="版本信息" append-to-body>
        <el-form ref="moreFormData" :model="currentRow" label-width="120px">
          <p class="mt15"></p>
          <el-form-item label="版本号">{{ currentRow.versionCode }}</el-form-item>
          <el-form-item label="版本日期">{{ currentRow.versionTime }}</el-form-item>
          <el-form-item label="上传日期">{{ currentRow.uploadTime }}</el-form-item>
          <el-form-item label="上传人">{{ currentRow.uploadUserName }}</el-form-item>
          <el-form-item label="数据名称">{{ currentRow.dataName }}</el-form-item>
          <!--<el-form-item label="数据范围">{{ currentRow.dataRangeStr }}</el-form-item>-->
          <el-form-item label="版本说明">{{ currentRow.versionDesc }}（此处是版本说明，<span style="color:red">限制300字以内</span> ）</el-form-item>
          <el-form-item label="数据说明">{{ currentRow.dataDesc }}（此处是数据说明，<span style="color:red">限制300字以内</span> ）</el-form-item>
          <el-form-item label="数据文件">
            <template #default="scope">
              <div>
                <p style="margin: 0px;" v-for="item in currentRow.dataFileList">
                  <u style="color:#107ce5;cursor: pointer;" @click="handleDownload(item)">{{ item.attachName }}</u>
                </p>
              </div>
            </template>
          </el-form-item>
          <el-form-item label="附件">
            <template #default="scope">
              <div>
                <p style="margin: 0px;" v-for="item in currentRow.attachmentList">
                  <u style="color:#107ce5;cursor: pointer;" @click="handleDownload(item)">{{ item.attachName }}</u>
                </p>
              </div>
            </template>
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="openMore=false">关闭</el-button>
          </div>
        </template>
      </el-dialog>
      <!-- 元数据信息 -->
      <el-dialog v-model="openData" width="800px" title="元数据信息" append-to-body :show-close="!isFirstOpen"
                 :close-on-click-modal="!isFirstOpen" :close-on-press-escape="!isFirstOpen">
        <el-form ref="ruleFormData" :model="formData" :rules="rules" label-width="120px">
          <p class="mt15"></p>
          <el-form-item label="上传人">{{ formData.uploadUser }}</el-form-item>
          <el-form-item label="上传日期">{{ formData.uploadTime }}</el-form-item>
          <el-form-item label="数据来源" prop="uploadSource">
            <el-input v-model="formData.uploadSource" placeholder="数据提供的部门、单位名称、下载的途径、来源网站等" clearable :disabled="!isFirstOpen" />
          </el-form-item>
          <!--<el-form-item label="数据类别" prop="type">{{ formData.dataType }}</el-form-item>-->
          <el-form-item label="数据级别" prop="dataScope" required>
            <el-row :gutter="20">
              <el-col :span="20">
                <el-form-item prop="dataRangeCountry" label-width="0px">
                  <el-select v-model="formData.dataRangeCountry" placeholder="请选择" style="width:178px" disabled>
                    <el-option v-for="item in [{ value: 1, label: '国家级' }, { value: 2, label: '省级' }]" :key="item.value"
                               :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item label="版本范围" prop="dataScope" required>
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item prop="dataRangeProvince" label-width="0px">
                  <el-select v-model="formData.dataRangeProvince" placeholder="省" style="width:100%" disabled>
                    <el-option label="全国" :value="null"></el-option>
                    <el-option v-for="item in provinceFormData1" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-select v-model="formData.dataRangeCity" placeholder="市" style="width:100%" disabled>
                  <el-option label="全部" :value="null"></el-option>
                  <el-option v-for="item in cityFormData1" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="6">
                <el-select v-model="formData.dataRangeArea" placeholder="区县" style="width:100%" disabled>
                  <el-option label="全部" :value="null"></el-option>
                  <el-option v-for="item in areaFormData1" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item label="是否空间数据" prop="isSpatialData" required>
            <el-radio-group v-model="formData.isSpatialData" disabled>
              <el-radio :label="1">空间数据</el-radio>
              <el-radio :label="0">非空间数据</el-radio>
            </el-radio-group>
          </el-form-item>

          <template v-if="formData.isSpatialData == '1'">
            <el-form-item label="空间数据类型" prop="spatialDataType">
              <el-radio-group v-model="formData.spatialDataType" :disabled="!isEdit">
                <el-radio :label="1">点</el-radio>
                <el-radio :label="2">线</el-radio>
                <el-radio :label="3">面</el-radio>
              </el-radio-group>
            </el-form-item>
            <div class="tab-title">基于坐标的空间参照系</div>
            <el-form-item label="坐标系类型">{{ formData.coordinateSystemType }}</el-form-item>
            <el-form-item label="坐标系名称">{{ formData.coordinateSystemName }}</el-form-item>
            <el-form-item label="英文缩写">{{ formData.coordinateSystemEnName }}</el-form-item>
            <!-- <el-form-item label="投影信息" prop="projectionInfo">
              <el-input v-model="formData.projectionInfo" placeholder="请输入投影信息" clearable :disabled="!isEdit" />
            </el-form-item> -->
          </template>
          <div class="tab-title">数据字段</div>
          <el-form-item label="字段个数" prop="fieldNum">
            <el-input v-model="formData.fieldNum" placeholder="请输入字段个数" clearable :disabled="!isEdit" />
          </el-form-item>
          <el-form-item label="字段条目" prop="fieldEntry">
            <el-input v-model="formData.fieldEntry" placeholder="请输入字段条目" clearable :disabled="!isEdit" />
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitFormYuan">保存</el-button>
            <el-button type="primary" @click="isEdit = true" v-if="!isFirstOpen">编辑</el-button>
            <el-button v-if="!isFirstOpen" @click="openData = false">取消</el-button>
          </div>
        </template>
      </el-dialog>
      <!--根据版本查询图层数据信息表格-->
      <!--基础数据信息表格-->
      <IndexTable v-if="resetClearAllBool==false && allTableDataBool==true"
                  :allTableDataBool="allTableDataBool"
                  :isSpatialDataBool="isSpatialDataBool"
                  :currentLayerName="currentLayerName"
                  :currentLayerCode="currentLayerCode"
                  :currentVersionCode="currentVersionCode"
                  :allTableDataList="allTableDataList"
                  :allTableTitleList="allTableTitleList"
                  :selectId="selectId"
                  :total="total"
                  :queryTableDataByPageBool="queryTableDataByPageBool"
      ></IndexTable>
      <!--添加数据-->
      <IndexAddData v-if="addDataType!=null && addDataType!=''"
          :level1DataTree="level1DataTree"
          :addDataType="addDataType"
          :openAddDataBool="addDataShowDivBool"
          :currentTifAttach="currentTifAttach"
          @closeAddData="closeAddData"
      ></IndexAddData>
      <!--图层图例-->
      <div v-if="showHideLegendDivBool" class="layerMap-legend">
        <!--滚动条-->
        <el-scrollbar max-height="500px">
          <p>图例</p>
          <div v-for="item in layerShowHideArray" :key="item.code" v-show="item.show" v-html="item.legendHtml">
          </div>
        </el-scrollbar>
      </div>
      <!--高程计算坡度坡向-->
      <div v-if="showComputeBool" class="computeDiv">
        <el-button type="primary" @click="computeSaveSlopeTif">生成坡度</el-button>
        <el-button type="primary" @click="computeSaveAspectTif">生成坡向</el-button>
        <el-button type="primary" @click="showImgcreate">生成图件</el-button>
      </div>
      <!--导入坡度-->
      <div v-show="activeRadioLabel=='dxdmpd'" class="computeDiv">
        <el-button type="primary" @click="uploadSlopeTifAspectTif('dxdmpd')">导入坡度</el-button>
      </div>
      <!--导入坡向-->
      <div v-show="activeRadioLabel=='dxdmpx'" class="computeDiv">
        <el-button type="primary" @click="uploadSlopeTifAspectTif('dxdmpx')">导入坡向</el-button>
      </div>
      <!--分区统计坡度坡向-->
      <!-- <div v-if="showCountBool" class="countDiv">
        <el-button v-if="activeRadioLabel=='dxdmpd'" type="primary" @click="countDivisionalSlopeTif">坡度分区统计</el-button>
      </div> -->
      <!--生成图件-->
      <PrintMap v-if="showImgcreateBool"
                :open="showImgcreateBool" :geom="printParams.geomText"
                :mapLevel1Category="printParams.mapLevel1Category" :mapLevel2Category="printParams.mapLevel2Category"
                :legendSetList="printParams.legendSetList" :tempLayersSetList="printParams.tempLayersSetList"
                @closeImgDialog="closeImgDialog"
      ></PrintMap>
    </div>
    <div class="uploadDialog" v-show="openUpload">
      <div class="close">
				<el-icon>
					<Close @click="closeUploadShp" />
				</el-icon>
			</div>
      <el-upload
        v-model:file-list="fileList"
        class="upload-demo"
        :action="uploadFileUrl"
        :before-remove="beforeRemove"
        :on-error="onError"
        :on-progress="handSuccess"
      >
        
        <template #trigger>
          <el-button type="primary">请选择文件</el-button>
        </template>
        <template #default>
          <el-button type="primary" style="margin-left: 10px" @click="saveUploadTif">确定</el-button>
        </template>
        <template #tip>
          <div class="el-upload__tip">
            只支持.tif文件格式!
          </div>
        </template>
      </el-upload>
    </div>
  </div>
</template>

<script setup>
//地图
import IndexMap from '@/map/dataManage/tifData/indexMap.vue';
import IndexTable from '@/map/dataManage/tifData/indexTable.vue';
import IndexAddData from '@/map/dataManage/tifData/indexAddData.vue';
import PrintMap from '@/map/slideAssess/distributionPatternAnalysis/printMap.vue';
import { getProvince, getChildArea } from "@/api/system/division";
import { getDataTypeTree, getSysDataVersion, queryDataByVersionCode,queryDataById } from "@/api/datamanage/basicData/indexMap.js";
import { getDataTypeLevel2AndDataTypeLevel3Tree, getSysDataVersion as getSysDataVersionYw, queryDataByVersionCode as queryDataByVersionCodeYw,queryDataById as queryDataByIdYw } from "@/api/datamanage/tifData/indexMap.js";
import { getFileMessage } from "@/api/datamanage/sysData/indexMap.js";
import { updateAdministrativeArea,delAdministrativeArea,delByIds,getDetail,getAdmin } from '@/api/datamanage/sysData/administrativeArea.js';
import { computeSlopeTif,computeAspectTif,findOneById,getAttachById,countSlopeTif,uploadTifFile,importSlopeTif,importAspectTif } from "@/api/datamanage/tifData/tifCompute.js";
import { ElMessageBox } from 'element-plus'
import { getUserId } from '@/utils/auth'
import { iServerHttp } from "@/map/projMap.js"
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/attachment/uploadFile"); // 上传的图片服务器地址
import { downLoadTifFile } from "@/api/system/attachFile.js";
import { nextTick } from 'vue';

const { proxy } = getCurrentInstance();
const props = defineProps(['dataType']);
const level1DataTree = ref(null);//数据类别一级code二级树
const loading = ref(false);
const activeName = ref("版本范围");
const openUpload = ref(false)
const fileList = ref([])
const activeNames = ref("0");//数据图层类型选择div默认展开的序号
const activeRadioLabel = ref(null);//激活显示版本号选择div的图层radio序号
const boxshow = ref(false);//是否显示选择数据div
const versionCodeDivShow = ref(false);//是否显示选择版本号div
const resetClearAllBool = ref(false);//是否重置清空全部图层数组
const versionCodeTableData = ref([]);//查询版本号数据列表
const addDataType = ref("");//选择添加数据类别
const isAllAdmin = ref(true);//是否国家级管理员
const isCountryId = ref('');//省级管理员的省份ID
const disabled1 = ref(false);//是否省份固定
const provinceData = ref([]);//省
const cityData = ref([]);//市
const areaData = ref([]); //区、县

//数据图层显示列表
const collapseLayerData = ref([]);
const selectdatas = ref([]);//勾选的数据
//添加数据
const addDataShowDivBool = ref(false);
//是否显示高程计算坡度坡向面板
const showComputeBool = ref(false);
//是否显示坡度坡向分区统计面板
const showCountBool = ref(false);
//是否分页查询表格数据
const queryTableDataByPageBool = ref(false);

const openMore = ref(false);
//元数据信息
const openData = ref(false);
const isFirstOpen = ref(true);
const isEdit = ref(false);
const provinceFormData1 = ref([]);//省
const cityFormData1 = ref([]);//市
const areaFormData1 = ref([]); //区、县

/*地图传参start*/
const completeRefreshData = ref(false);//防止刷新后地图不显示
const allListData = ref([]);//地图显示数据列表
const allRadioIndexData = ref([]);//全部序号列表
//选择图层的版本号数据列表
const typeCodeDataList = ref([]);
//是否显示图层表格数据列表
const allTableDataBool = ref(false);
//图层表格数据列表
const allTableDataList = ref([]);
//表头字段数据列表
const allTableTitleList = ref([]);
//是否为空间数据
const isSpatialDataBool = ref(false);
//总数据量
const total = ref(0);
//当前选中行数据
const currentRow = ref(null);
//当前数据类型图层名称
const currentLayerName = ref("");
//当前数据类型code
const currentLayerCode = ref("");
//当前数据版本号
const currentVersionCode = ref("");
//当前tif文件路径
const currentTifFilePath = ref("");
//当前tif文件信息
const currentTifAttach = ref(null);
//选中1条数据的ID
const selectId = ref("");

//数据类型
const dataTypeInfoArray = ref([
  // {name: 'DEM高程数据', radioLabel: '68', code: 'demgcsj', table:"",url:iServerHttp()+"/iserver/services/map-demtif/rest/maps/坐标转换后的四川dem90米_202305100949_1683683386203",zIndex:6,fieldId:""},
  // {name: '地形地貌坡度', radioLabel: 'dxdmpd', code: 'dxdmpd', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/坡度_1683855831608",zIndex:6,fieldId:""},
  // {name: '地形地貌坡向', radioLabel: 'dxdmpx', code: 'dxdmpx', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/坡向_1683855872669",zIndex:6,fieldId:""},
  {name: 'DEM高程数据', radioLabel: '68', code: 'demgcsj', table:"",url:iServerHttp()+"/iserver/services/map-demtif/rest/maps/",zIndex:6,fieldId:""},
  {name: '地形地貌坡度', radioLabel: 'dxdmpd', code: 'dxdmpd', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/",zIndex:6,fieldId:""},
  {name: '地形地貌坡向', radioLabel: 'dxdmpx', code: 'dxdmpx', table:"",url:iServerHttp()+"/iserver/services/map-dzzhTifFile/rest/maps/",zIndex:6,fieldId:""},
]);

/*地图传参end*/
const dataRangeProvinceCheck = (rule, value, callback) => {
  if (!value) {
    //if (!value && queryParams.value.dataRangeCountry == "2") {
    callback(new Error('请选择省'))
  } else if (value == undefined && queryParams.value.dataRangeCountry == undefined) {
    callback()
  } else {
    callback()
  }
}

const data = reactive({
  queryParams: {
    dataTypeCode: '',
    dataRangeCountry: '1',
    dataRangeProvince: '全国',
    dataRangeCity: '',
    dataRangeArea:'',
    dataRangeText:'',//版本范围当前选择内容
    dataLayerText:'',//数据图层当前选择内容
    dataTypeCodeSearchText:'',//搜索版本号输入框文本
  },
  queryParamsNew: {
    dataRangeProvince: '',//省ID
    dataRangeCity: '',//市ID
    dataRangeArea:'',//区县ID
  },
  form: {
    banben: '保存新版本',
    dataScope: '1',
    type: '1',
    dataFileId: [],
    versionCode: '',
  },
  formData: {
    dataScope: '1',
    type: '1',
  },
  rules: {
    dataRangeCountry: [{ required: true, message: "数据级别不能为空", trigger: "change" }],
    dataRangeProvince: [{ required: true, message: "省不能为空", trigger: "change", validator: dataRangeProvinceCheck }],
    dataType: [{ required: true, message: "数据类别不能为空", trigger: "change" }],
    dataType2: [{ required: true, message: "子数据类别不能为空", trigger: "change" }],
    dataName: [{ required: true, message: "数据名称不能为空", trigger: "blur" }],
    dataDesc: [{ required: true, message: "数据说明不能为空", trigger: "blur" }],
    versionCode: [{ required: true, message: "版本号不能为空", trigger: "change" }],
    versionTime: [{ required: true, message: "版本日期不能为空", trigger: "change" }],
    versionDesc: [{ required: true, message: "版本说明不能为空", trigger: "blur" }],
    updateDesc: [{ required: true, message: "更新说明不能为空", trigger: "blur" }],
    dataFileIds: [{ required: true, message: "数据文件不能为空", trigger: "blur" }],
    dataFrom: [{ required: true, message: "数据来源不能为空", trigger: "blur" }],
    uploadSource: [{ required: true, message: "数据来源不能为空", trigger: "blur" }],
    spatialDataType: [{ required: true, message: "空间数据类型不能为空", trigger: "blur" }],
    // projectionInfo: [{ required: true, message: "投影信息不能为空", trigger: "blur" }],
    fieldNum: [{ required: true, message: "字段个数不能为空", trigger: "blur" }, { pattern: /^[1-9]\d*$/, message: '请输入大于0的整数！', trigger: 'change' }],
    fieldEntry: [{ required: true, message: "字段条目不能为空", trigger: "blur" }, { pattern: /^[1-9]\d*$/, message: '请输入大于0的整数！', trigger: 'change' }],
  },
  rulesNew:{
    dataRangeProvince: [{ required: true, message: "省不能为空", trigger: "change", validator: dataRangeProvinceCheck }],
  },
  collapseData:{
    showHideBool:true,
    layerName:'',//选中图层名称
  },
  typeCodeInfo:{
    //typeInfo:'针对本版本说明文字，限制300字以内',//版本说明
    typeInfo:'针对本版本说明文字，限制300字以内,针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，',
    //dataInfo:'针对本数据说明文字，限制300字以内',//数据说明
    dataInfo:'针对数据说明文字，限制300字以内,针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，限制300字以内针对本版本说明文字，',
    uploadUser:'张三',//上传人
  },
  //用于生成图件
  printParams:{
    geomText:"",//空间数据
    mapLevel1Category:"6",//一级图件分类：地质灾害危险性评估-基础数据
    mapLevel2Category:"8",//二级图件分类：地形地貌图
    legendSetList:[],//图层（临时图层）url列表--用于显示图例
    tempLayersSetList:[],//图层（临时图层）url列表--用于显示图层
  },
})
const { queryParams, queryParamsNew, form, rules, rulesNew, formData,collapseData,typeCodeInfo,printParams } = toRefs(data);

// 改变版本范围
const changeRadio = (value)=>{
  if(value=="1"){//国家级
    queryParams.value.dataRangeProvince = "全国";
    queryParams.value.dataRangeCity = "";
    queryParams.value.dataRangeArea = "";
    queryParamsNew.value.dataRangeProvince = "";
    queryParamsNew.value.dataRangeCity = "";
    queryParamsNew.value.dataRangeArea = "";
    disabled1.value = false;
    isAdminCountryId1()
  }else{//省级
    queryParams.value.dataRangeProvince = "";
    queryParams.value.dataRangeCity = "";
    queryParams.value.dataRangeArea = "";
    queryParamsNew.value.dataRangeProvince = "";
    queryParamsNew.value.dataRangeCity = "";
    queryParamsNew.value.dataRangeArea = "";
    //权限控制
    isAdminCountryId();
  }
}
function closeUploadShp() {
  openUpload.value = false
  fileList.value = []
}
function beforeRemove(file, fileList) {
  fileList.value = fileList;
}
function onError(res,file,uploadFiles) {
  fileList.value = [];
  proxy.$modal.msgError('上传失败');
}
function handleExceed(files, uploadFiles) {
  proxy.$modal.msgError("限制上传1个.tif文件");
}
//上传文件时
function handSuccess(event, file, fList) {
  let type = file.name.split('.')[1]
  if (type != 'tif') {
    // fileList.value = fList.filter(item => item.name != file.name)
    fileList.value = []
    proxy.$modal.msgError(`请选择.tif格式文件!`);
  }
}
function saveUploadTif () {
  if(fileList.value.length != 0) {
    loading.value = true;
    openUpload.value = false
    // addDataType.value = uploadType.value
    // addDataShowDivBool.value = true
    const formData = new FormData()
    formData.append('file', fileList._rawValue[0].raw)
    uploadTifFile(formData).then(res => {
      getAttachById(res.data[0].attachId).then((response) => {
        nextTick(() => {
          console.log("获取tif文件详情");
          console.log(response.data);
          let result = response.data;
          if(result && result.fileDirId && result.attachPath && result.attachName.indexOf(".tif")!=-1){
            //当前tif文件信息
            currentTifAttach.value = result;
            if(uploadType.value=='dxdmpd'){
              //根据上传的坡度tif文件发布超图图层
              importSlopeTifFile(result);
            }else if(uploadType.value=='dxdmpx'){
              //根据上传的坡向tif文件发布超图图层
              importAspectTifFile(result);
            }
          }
          loading.value = false;
        });
      }).catch(err => {
        loading.value = false;
      });
    }).catch(err => {
      loading.value = false;
    });
  }else{
    proxy.$modal.msgError(`请上传.tif格式文件!`);
  }
}

//根据上传的坡度tif文件发布超图图层
const importSlopeTifFile = (attachResult)=>{
  let tifFileName = attachResult.attachName.split(".")[0];
  if(tifFileName){
    //根据上传的坡度tif文件发布超图图层
    importSlopeTif(tifFileName).then((response) => {
      nextTick(() => {
        console.log("计算坡度");
        console.log(response.data);
        let result = response.data;
        let msg = result[0];
        if(msg=="生成成功"){
          let filePath = result[1];
          let dataLength = result[2];
          //当前tif文件路径
          currentTifFilePath.value = filePath;
          //当前tif文件信息
          currentTifAttach.value = attachResult;
          loading.value = false;
          //文件数据长度
          attachResult.dataLength = dataLength;
          //数据类型
          addDataType.value = uploadType.value;
          handleAdd();//添加数据
          // proxy.$modal.msgSuccess("生成成功");
          let attachName = attachResult.attachName;
          let tifFileName = attachName.split(".")[0];
          console.log("发布tif图层名称："+tifFileName);
        }else{
          loading.value = false;
          proxy.$modal.msgWarning(msg);
        }
      });
    }).catch(err => {
      loading.value = false;
      proxy.$modal.msgWarning("生成失败");
    });
  }
}

//根据上传的坡向tif文件发布超图图层
const importAspectTifFile = (attachResult)=>{
  let tifFileName = attachResult.attachName.split(".")[0];
  if(tifFileName){
    //根据上传的坡向tif文件发布超图图层
    importAspectTif(tifFileName).then((response) => {
      nextTick(() => {
        console.log("计算坡向");
        console.log(response.data);
        let result = response.data;
        let msg = result[0];
        if(msg=="生成成功"){
          let filePath = result[1];
          let dataLength = result[2];
          //当前tif文件路径
          currentTifFilePath.value = filePath;
          //当前tif文件信息
          currentTifAttach.value = attachResult;
          loading.value = false;
          //文件数据长度
          attachResult.dataLength = dataLength;
          //数据类型
          addDataType.value = uploadType.value;
          handleAdd();//添加数据
          // proxy.$modal.msgSuccess("生成成功");
          let attachName = attachResult.attachName;
          let tifFileName = attachName.split(".")[0];
          console.log("发布tif图层名称："+tifFileName);
        }else{
          loading.value = false;
          proxy.$modal.msgWarning(msg);
        }
      });
    }).catch(err => {
      loading.value = false;
      proxy.$modal.msgWarning("生成失败");
    });
  }
}

//权限控制
function isAdminCountryId(){
  if(!isAllAdmin.value){
    disabled1.value = true;
    let list = provinceData.value;
    for(let i=0;i<list.length;i++){
      if(list[i].id==isCountryId.value){//省份
        queryParamsNew.value.dataRangeProvince = list[i].id;
        queryParams.value.dataRangeProvince = list[i].name;
        getChildArea(list[i].id).then(response => {
          cityData.value = response.data;
        });
        break;
      }
    }
    areaData.value = [];
  }else{
    disabled1.value = false;
    cityData.value = [];
    areaData.value = [];
  }
}

//权限控制
function isAdminCountryId1(){
  if(!isAllAdmin.value){
      provinceData.value=provinceData.value.filter(item=>item.id==isCountryId.value);
  }
}

const showDataRangeTab = (value)=>{
  activeName.value = '版本范围';
  //收起数据图层
  hideCollapseDiv();
}

const showDataLayerTab = (value)=>{
  if(queryParams.value.dataRangeText==""){
    proxy.$modal.msgWarning("请先设置版本范围");
  }else{
    activeName.value = '数据图层';
  }
}

//确定版本范围
const submitSelect = (value)=>{
  proxy.$refs["queryRef"].validate(valid => {
    if (valid) {
      //重置数据图层
      resetCollapseDiv();
      collapseData.value.showHideBool=true;//展开数据图层
      let country = queryParams.value.dataRangeCountry;
      if(country=="1"){
        country = "国家级数据";
      }else{
        country = "省级数据";
      }
      let province = isUndefined(queryParams.value.dataRangeProvince);
      let city = isUndefined(queryParams.value.dataRangeCity);
      let area = isUndefined(queryParams.value.dataRangeArea);
      queryParams.value.dataRangeText = country+"，"+province+city+area;
      activeName.value = '数据图层';
    }
  });
}

//判断是否无值则返回空字符串，“全部”返回空字符串
function isUndefined(value){
  if(value==undefined || value==null || value=='全部'){
    value = "";
  }
  return value;
}

//重置版本范围
const resetSelect = ()=>{
  proxy.resetForm("queryRef");
  queryParams.value.dataRangeProvince = "";
  queryParams.value.dataRangeCity = "";
  queryParams.value.dataRangeArea = "";
  queryParams.value.dataRangeText = "";
  queryParamsNew.value.dataRangeProvince = "";
  queryParamsNew.value.dataRangeCity = "";
  queryParamsNew.value.dataRangeArea = "";
  //版本范围当前选择内容
  let country = queryParams.value.dataRangeCountry;
  if(country=="1"){
    country = "国家级数据";
    queryParams.value.dataRangeProvince = "全国";//默认全国
    isAdminCountryId1()
  }else{
    country = "省级数据";
    //权限控制
    isAdminCountryId();
  }
  queryParams.value.dataRangeText = country;
}

/** 获取省列表 */
function getProvinceData() {
  getProvince().then(response => {
    provinceData.value = response.data;
  });
}
//选择省
function chooseProvince(value) {
  queryParams.value.dataRangeCity = "";
  queryParams.value.dataRangeArea = "";
  queryParamsNew.value.dataRangeCity = "";
  queryParamsNew.value.dataRangeArea = "";
  cityData.value = [];
  areaData.value = [];
  if(value==""){
    queryParamsNew.value.dataRangeProvince = "";
  }else{
    if(value=="全国"){
      queryParams.value.dataRangeProvince = value;
      queryParamsNew.value.dataRangeProvince = "";
    }else{
      let list = provinceData.value;
      for(let i=0;i<list.length;i++){
        if(list[i].name==value){
          queryParamsNew.value.dataRangeProvince = list[i].id;
          queryParams.value.dataRangeProvince = list[i].name;
          getChildArea(list[i].id).then(response => {
            cityData.value = response.data;
          });
          break;
        }
      }
    }
  }
}
//选择市
function chooseCity(value) {
  queryParams.value.dataRangeArea = "";
  queryParamsNew.value.dataRangeArea = "";
  areaData.value = [];
  if(value==""){
    queryParamsNew.value.dataRangeCity = "";
  }else{
    if(value=="全部"){
      queryParams.value.dataRangeCity = value;
      queryParamsNew.value.dataRangeCity = "";
    }else{
      let list = cityData.value;
      for(let i=0;i<list.length;i++) {
        if (list[i].name == value) {
          queryParamsNew.value.dataRangeCity = list[i].id;
          queryParams.value.dataRangeCity = list[i].name;
          getChildArea(list[i].id).then((response) => {
            areaData.value = response.data;
          });
          break;
        }
      }
    }
  }
}
//选择区县
function chooseArea(value){
  if(value==""){
    queryParamsNew.value.dataRangeArea = "";
  }else{
    if(value=="全部"){
      queryParams.value.dataRangeArea = value;
      queryParamsNew.value.dataRangeArea = "";
    }else{
      let list = areaData.value;
      for(let i=0;i<list.length;i++) {
        if (list[i].name == value) {
          queryParamsNew.value.dataRangeArea = list[i].id;
          queryParams.value.dataRangeArea = list[i].name;
        }
      }
    }
  }
}

const handleChange = (val) => {
  console.log(val)
}

//收起选择数据div
const hideTabBoxDiv = () => {
  if(boxshow.value){
    //收起数据图层
    hideCollapseDiv();
    boxshow.value = false;
  }else{
    boxshow.value = true;
  }
}

//收起数据图层
const hideCollapseDiv = () => {
  showComputeBool.value = false
  //获取数据图层当前选择内容
  getDataLayerText();
  collapseData.value.showHideBool=false;
  versionCodeDivShow.value = false;
  activeRadioLabel.value = null;
  queryParams.value.dataTypeCodeSearchText = "";//清空搜索内容
}

//重置数据图层
const resetCollapseDiv = () => {
  //清空图层选择的版本号列表
  let datalist = typeCodeDataList.value;
  for(let i=0;i<datalist.length;i++) {
    datalist[i].typeCodeSelectData = [];
  }
  activeRadioLabel.value = null;
  versionCodeDivShow.value = false;
  queryParams.value.dataLayerText = "";
  resetClearAllBool.value = true;//是否重置清空全部图层数组
  queryParams.value.dataTypeCodeSearchText = "";//清空搜索内容
  getLegendHtml(null);//清空图例
}

//重置数据图层和版本范围
const resetAllCollapseDiv = () => {
  //重置数据图层
  resetCollapseDiv();
  //重置版本范围
  //resetSelect();
  activeName.value = '版本范围';
}

//根据序号值获取版本数据
const getLayerInfoByRadioIndex = (radioLabel) => {
  let data = null;
  let datalist = typeCodeDataList.value;
  for(let i=0;i<datalist.length;i++){
    if(datalist[i].radioLabel==radioLabel){
      data = datalist[i];
      break;
    }
  }

  return data;
}

//图层选择绑定值变化时触发的事件
const radioChange = () => {
  console.log("图层选择");
  //隐藏选择版本号div
  versionCodeDivShow.value = false;
  queryParams.value.dataTypeCodeSearchText = "";//清空搜索内容
  versionCodeTableData.value = [];//清空表数据
  let radioLabel = activeRadioLabel.value;
  //根据序号值获取版本数据
  let data = getLayerInfoByRadioIndex(radioLabel);
  if(data!=null){
    //获取图层名称
    collapseData.value.layerName = data.name;
    if(data.name!="DEM高程数据"){
      collapseData.value.layerName = data.name + "数据";
    }
  }
  selectdatas.value = [];//清空勾选数据
  //查询版本列表
  querySysDataVersion();
}

//设置勾选的表数据
const changeState = () => {
  console.log("设置勾选的表数据");
  let radioLabel = activeRadioLabel.value;
  //根据序号值获取版本数据
  let data = getLayerInfoByRadioIndex(radioLabel);
  if(data!=null){
    console.log(data.typeCodeSelectData);
    //设置勾选的表数据
    selectdatas.value = data.typeCodeSelectData;
  }
  if(proxy.$refs.versionCodeTable){
    let tableData = versionCodeTableData.value;
    let selectDataArray = selectdatas.value;
    if(tableData){
      for (let i = 0; i < tableData.length; i++) {
        if (selectDataArray.indexOf(tableData[i]["versionCode"]) != -1) {//勾选
          proxy.$refs.versionCodeTable.toggleRowSelection(
              tableData[i],
              true
          );
        }else{//不勾选
          proxy.$refs.versionCodeTable.toggleRowSelection(
              tableData[i],
              false
          );
        }
      }
    }
  }
}

//显示隐藏折叠面板
const showHideCollapse = (value) => {
  if(document.getElementById(value).style.display == "none"){
    document.getElementById(value).style.display = "block";
  }else{
    document.getElementById(value).style.display = "none";
  }
}

/** 单击选择行 */
function clickRow(row) {
  proxy.$refs.versionCodeTable.toggleRowSelection(row);
  //设置图层选择的版本号列表
  setActiveTypeCodeList(row);
}

/** 多选框选中数据 */
function handleSelectionChange(selecteds, row) {
  //设置图层选择的版本号列表
  setActiveTypeCodeList(row);
}

//设置图层选择的版本号列表（添加、移除）并查询图层数据
function setActiveTypeCodeList(row){
  let bool = false;//是否添加版本号
  //添加、移除版本号
  if (!selectdatas.value.includes(row.versionCode)) {
    selectdatas.value.push(row.versionCode);//添加
    bool = true;
  } else {
    selectdatas.value.forEach((id, index) => {
      if (id === row.versionCode) {
        selectdatas.value.splice(index, 1);//移除
      }
    });
    bool = false;
  }
  //清空当前行数据
  currentRow.value = null;
  console.log(selectdatas.value);
  console.log("设置图层选择的版本号列表");
  console.log(row);
  let radioLabel = activeRadioLabel.value;
  //根据序号值获取版本数据
  let data = getLayerInfoByRadioIndex(radioLabel);
  if(data!=null){
    console.log("根据序号值获取版本数据");
    console.log(data);
    //设置图层对应的选择版本号列表
    data.typeCodeSelectData = selectdatas.value;
    //是否为空间数据
    let spatialBool = true;
    isSpatialDataBool.value = spatialBool;
    resetClearAllBool.value = false;//是否重置清空全部图层数组
    if(spatialBool){//空间数据
      if(bool){//添加版本号
        //根据图层类型查询图层版本号数据
        //查询版本号对应图层数据
        getDataByVersionCode(row,true);
      }else{//移除版本号s
        allListData.value = [radioLabel,row.versionCode,[],false,null];
        allTableDataBool.value = false;
        allTableDataList.value = [];//清空图层表格数据列表
        allTableTitleList.value = [];
      }
    }else{//非空间数据
      if(bool) {//添加版本号
        //查询版本号对应非空间数据
        getDataByVersionCode(row,false);
      }else{
        allTableDataBool.value = false;
        allTableDataList.value = [];//清空图层表格数据列表
        allTableTitleList.value = [];
      }
    }
  }
}

//获取数据图层当前选择内容
function getDataLayerText(){
  let text = "";
  let datalist = typeCodeDataList.value;
  for(let i=0;i<datalist.length;i++){
    let radioLabel = datalist[i].radioLabel;
    let selectArray = datalist[i].typeCodeSelectData;
    if(selectArray.length>0){
      //根据序号获取图层全名数组
      let fullNameArr = getLayerFullNameArr(radioLabel);
      if(fullNameArr.length==2){
        text += fullNameArr[0] + "/" + fullNameArr[1] + "，";
      }else{
        continue;
      }
      for(let j=0;j<selectArray.length;j++){
        let versionCode = selectArray[j];
        if(j>0){
          text += "，";
        }
        text += "版本号"+versionCode;
      }
      text += "；";
    }
  }
  queryParams.value.dataLayerText = text;
}

//根据序号获取图层全名数组
function getLayerFullNameArr(radioLabel){
  let fullNameArr = [];
  let list = collapseLayerData.value;
  for(let i=0;i<list.length;i++){
    let childList = list[i].children;
    for(let j=0;j<childList.length;j++){
      if(childList[j].radioLabel==radioLabel){
        let parentName = list[i].label;
        let layerName = childList[j].name;
        fullNameArr = [parentName,layerName];
        break;
      }
    }
  }

  return fullNameArr;
}

const alertSelect = () => {
  ElMessageBox.alert('请选择要展示的数据及版本', '系统提示', {
    confirmButtonText: '确定',
    callback: () => {
      boxshow.value = true;
    },
  })
}

//打开添加数据面板
const handleAdd = ()=>{
  if(addDataType.value!=""){
    addDataShowDivBool.value = true;
  }else{
    proxy.$modal.msgWarning("请先选择添加数据类别");
  }
}
//关闭添加数据面板
const closeAddData = ()=>{
  addDataShowDivBool.value = false;
}

//切换添加数据类型
const chooseAddDataType = ()=> {
  let tempType = addDataType.value;
  addDataType.value = "";
  nextTick(() => {
    addDataType.value = tempType;
  });
}

//获取数据图层显示列表
const getAllTreeData = (level2DataType)=>{
  /**
   * dictCode :类别code 数据类别的dictItemCode
   * 水系 sx
   * 地形地貌 高程demgc
   * 活断层 hdc
   * 道路 dl
   * 地层岩性 dcyx
   * 地震动峰值加速度数据 pgakj
   * 气候qx
   */
  //2级数据类别信息
  let dictItemName = "";
  let dictItemCode = "";
  if(level2DataType=="demgc"){
    dictItemName = "DEM高程";
    dictItemCode = "demgc";
  }
  if(dictItemCode){
    //查询数据类别树
    getDataTypeTree(dictItemCode).then((response) => {
      nextTick(() => {
        console.log("查询数据类别树");
        console.log(response.data);
        let list = response.data;
        let collapseLayerDataArray = [];
        let typeCodeDataArray = [];
        let allRadioIndexArray = [];
        let childrenData = [];
        if(list!=null && list.length>0){
          for(let i=0;i<list.length;i++){
            let data = list[i];
            childrenData.push({
              name: data.dictItemName,
              radioLabel: data.dictItemId,
              dictItemCode: data.dictItemCode,
              spaceBool:true,//是否空间数据
            });
            //选择图层的版本号数据列表
            typeCodeDataArray.push({
              name: data.dictItemName,
              radioLabel: data.dictItemId,
              dictItemCode: data.dictItemCode,
              spaceBool:true,//是否空间数据
              typeCodeSelectData:[],
            });
            //全部序号列表
            allRadioIndexArray.push(data.dictItemId);
          }
        }
        //数据类别信息
        let collapseData = {
          value:dictItemCode,
          label: dictItemName,
          children: childrenData,
          dictItemCode: dictItemCode,
        };
        collapseLayerDataArray.push(collapseData);
        //默认展开显示
        activeNames.value = dictItemCode;
        //数据图层显示列表
        collapseLayerData.value = collapseLayerDataArray;
        //选择图层的版本号数据列表
        typeCodeDataList.value = typeCodeDataArray;
        //全部序号列表
        allRadioIndexData.value = allRadioIndexArray;
        //获取业务数据图层显示列表
        getAllYwTreeData("dxdmsj");
      });
    });
  }
}

//获取业务数据图层显示列表
const getAllYwTreeData = (dataType)=>{
  /**
   * dictCode :1级数据类别code
   * 地形地貌数据 dxdmsj
   */
  //1级数据类别信息
  if(dataType){
    //查询数据类别树
    getDataTypeLevel2AndDataTypeLevel3Tree(dataType).then((response) => {
      nextTick(() => {
        console.log("查询业务数据类别树");
        console.log(response.data);
        let result = response.data;
        level1DataTree.value = result;//1级数据类别树
        let list = result.children;
        // allLevel1SjlbList.value = list;//2级数据类别
        //获取基础数据高程
        let collapseLayerDataArray = collapseLayerData.value;
        let typeCodeDataArray = typeCodeDataList.value;
        let allRadioIndexArray = allRadioIndexData.value;
        let childrenData = [];
        if(list!=null && list.length>0){
          for(let i=0;i<list.length;i++){
            let data = list[i];
            childrenData.push({
              name: data.dictItemName,
              radioLabel: data.dictItemCode,
              dictItemCode: data.dictItemCode,
              spaceBool:true,//是否空间数据
            });
            //选择图层的版本号数据列表
            typeCodeDataArray.push({
              name: data.dictItemName,
              radioLabel: data.dictItemCode,
              dictItemCode: data.dictItemCode,
              spaceBool:true,//是否空间数据
              typeCodeSelectData:[],
            });
            //全部序号列表
            allRadioIndexArray.push(data.dictItemCode);
          }
        }
        //数据类别信息
        let collapseData = {
          value:result.dictCode,
          label: result.dictName,
          children: childrenData,
          dictItemCode: result.dictCode,
        };
        collapseLayerDataArray.push(collapseData);
        //默认展开显示
        // activeNames.value = result.dictCode;
        //数据图层显示列表
        collapseLayerData.value = collapseLayerDataArray;
        //选择图层的版本号数据列表
        typeCodeDataList.value = typeCodeDataArray;
        //全部序号列表
        allRadioIndexData.value = allRadioIndexArray;
        //显示地图模块
        completeRefreshData.value = true;
      });
    });
  }
}

//查询版本列表
const querySysDataVersion = ()=>{
  let radioLabel = activeRadioLabel.value;
  if(radioLabel=="68"){//高程
    //是否显示高程计算坡度坡向面板
    showComputeBool.value = true;
    //是否显示坡度坡向分区统计面板
    showCountBool.value = false;
    //查询版本列表（基础数据）
    querySysDataVersionBasic();
  }else if(radioLabel=="dxdmpd" || radioLabel=="dxdmpx"){
    //是否显示高程计算坡度坡向面板
    showComputeBool.value = false;
    //是否显示坡度坡向分区统计面板
    showCountBool.value = true;
    //查询版本列表（业务数据）
    querySysDataVersionYw();
  }
}

//查询版本列表（基础数据）
const querySysDataVersionBasic = ()=>{
  console.log(queryParamsNew.value);
  let params = {
    dataRangeCountry : queryParams.value.dataRangeCountry,//1-国家级， 2-省级
    dataRangeProvince : queryParamsNew.value.dataRangeProvince,//省份id
    dataRangeCity : queryParamsNew.value.dataRangeCity,//市id
    dataRangeArea : queryParamsNew.value.dataRangeArea,//区县id
    dataType2 : activeRadioLabel.value,//二级数据类别code
    versionCode : queryParams.value.dataTypeCodeSearchText,//版本号
  }
  //查询版本列表
  getSysDataVersion(params).then((response) => {
    nextTick(() => {
      console.log("查询版本列表");
      console.log(response.data);
      //显示选择版本号div
      versionCodeDivShow.value = true;
      //版本数据列表
      // versionCodeTableData.value = response.data.list;
      versionCodeTableData.value = response.data;
      nextTick(() => {
        //设置勾选的表数据
        changeState();
      });
    });
  });
}

//查询版本列表（业务数据）
const querySysDataVersionYw = ()=>{
  let params = {
    dataRangeCountry : queryParams.value.dataRangeCountry,//1-国家级， 2-省级
    province : queryParamsNew.value.dataRangeProvince,//省份id
    city : queryParamsNew.value.dataRangeCity,//市id
    area : queryParamsNew.value.dataRangeArea,//区县id
    dataType2 : activeRadioLabel.value,//二级数据类别code
    versionCode : queryParams.value.dataTypeCodeSearchText,//版本号
  }
  //查询版本列表
  getSysDataVersionYw(params).then((response) => {
    nextTick(() => {
      console.log("查询版本列表");
      console.log(response.data);
      //显示选择版本号div
      versionCodeDivShow.value = true;
      //测试数据
      versionCodeTableData.value = response.data;
      nextTick(() => {
        //设置勾选的表数据
        changeState();
      });
    });
  });
}

//查询版本号对应图层数据
const getDataByVersionCode = (row,spatialBool)=>{
  console.log("开始查询版本号对应图层数据");
  console.log(row);
  let typeCode = row.dataTypeLevel3Code;
  if(typeCode==undefined){//业务数据
    typeCode = row.dataTypeLevel2;
    //是否显示坡度坡向分区统计面板
    showCountBool.value = true;
    //是否显示高程计算坡度坡向面板
    showComputeBool.value = false;
    //当前tif文件路径
    currentTifFilePath.value = "";
    let attachId = row.dataFileIds;
    //根据文件ID获取tif文件信息
    getAttachFileDataById(row.versionCode,attachId,"","");
  }else{//基础数据
    //是否显示高程计算坡度坡向面板
    showComputeBool.value = true;
    //是否显示坡度坡向分区统计面板
    showCountBool.value = false;
    //当前tif文件路径
    currentTifFilePath.value = "";
    let dataFileList = row.dataFileList;
    if(dataFileList && dataFileList.length>0){
      for(let i=0;i<dataFileList.length;i++){
        if(dataFileList[i].name.indexOf(".tif")!=-1){
          let id = dataFileList[i].id;
          //根据高程文件ID获取tif文件地址
          findTifFilePathById(row.versionCode,id);
          break;
        }
      }
    }
  }
  let versionCode = row.versionCode;
  allTableDataBool.value = false;
  allTableDataList.value = [];//清空图层表格数据列表
  allTableTitleList.value = [];
  //当前行数据
  currentRow.value = row;
  //获取数据图层名称
  currentLayerName.value = getDictItemNameByCode(typeCode);
  //当前数据类型code
  currentLayerCode.value = typeCode;
  //当前数据版本号
  currentVersionCode.value = versionCode;
  //选中1条数据的ID
  selectId.value = "";

  /*let radioLabel = activeRadioLabel.value;
  if(spatialBool){//空间数据
    // allListData.value = [radioLabel,row.versionCode,resultList.data,true,null];//显示图层数据列表
    allListData.value = [radioLabel,row.versionCode,[],true,null];//显示超图图层
  }*/

  /*loading.value = true;

  let params = {
    typeCode : typeCode,//三级数据类别（数据表）code
    versionCode : versionCode,//版本号
    page:1,//页码
    rows:10,//分页数据量
  }
  //查询版本号对应图层数据
  queryDataByVersionCode(params).then((response) => {
    nextTick(() => {
      console.log("查询版本号对应图层数据结果");
      console.log(response.data);
      let resultList = response.datas;//data,title,page,rows,total,totalPage
      if(resultList){
        let totalPage = resultList.totalPage;
        allTableDataList.value = resultList.data;//图层表格数据列表
        allTableTitleList.value = resultList.title;//表头字段列表
        total.value = resultList.total;//总数据量
        let radioLabel = activeRadioLabel.value;
        if(spatialBool){//空间数据
          // allListData.value = [radioLabel,row.versionCode,resultList.data,true,null];//显示图层数据列表
          allListData.value = [radioLabel,row.versionCode,[],true,null];//显示超图图层
        }
        allTableDataBool.value = true;//显示表格
      }
      loading.value = false;
    });
  }).catch(err => {
    loading.value = false;
  });*/
}

//根据ID查询数据属性表
const getDetailDataById = (temp)=>{
  console.log("开始根据ID查询数据属性表");
  let typeCode = temp.typeCode;
  let id = temp.id;
  let params = {
    typeCode : typeCode,//三级数据类别（数据表）code
    id : id,
  }
  allTableDataBool.value = false;
  allTableDataList.value = [];//清空根据ID查询数据属性表
  allTableTitleList.value = [];
  //获取数据图层名称
  currentLayerName.value = getDictItemNameByCode(typeCode);
  //当前数据类型code
  currentLayerCode.value = typeCode;
  //当前数据版本号
  currentVersionCode.value = "";
  //选中1条数据的ID
  selectId.value = id;
  //是否为空间数据
  isSpatialDataBool.value = true;
  //根据ID查询数据属性表
  queryDataById(params).then((response) => {
    nextTick(() => {
      console.log("根据ID查询数据属性表");
      console.log(response.data);
      let resultList = response.data;//data,title
      allTableDataList.value = [resultList.data];
      allTableTitleList.value = resultList.title;//表头字段列表
      allTableDataBool.value = true;
      total.value = 1;
    });
  });
}

//根据三级数据类别（数据表）code获取数据图层名称
const getDictItemNameByCode = (typeCode) => {
  let dictItemName = "";
  let list = typeCodeDataList.value;
  for(let i=0;i<list.length;i++){
    if(list[i].dictItemCode==typeCode){
      dictItemName = list[i].name;
      break;
    }
  }

  return dictItemName;
}

function admin(){
  const userId = getUserId()
  getAdmin({userId:userId}).then(res=>{
    isAllAdmin.value = res.data.isCountry;
    isCountryId.value = res.data.provinceId
  })
}

const showHideLegendDivBool = ref(false);//是否显示图例
const layerShowHideArray = ref([]);//图层是否显示数组
function setLayerShowHideArray(){
  let showHideArray = [];
  let dataTypeArray = dataTypeInfoArray.value;
  for(let i=0;i<dataTypeArray.length;i++){
    let item = dataTypeArray[i];
    showHideArray.push({ code: item.code, name: item.name, show:false,legendHtml:"" });
  }
  layerShowHideArray.value = showHideArray;
}
//图例
const getLegendHtml = (obj)=>{
  //图层显示隐藏数组
  let showHideArray = layerShowHideArray.value;
  if(obj!=null){
    for(let i=0;i<showHideArray.length;i++){
      if(showHideArray[i].name==obj.name){
        showHideArray[i].show = obj.show;
        showHideArray[i].legendHtml = obj.legendHtml;//显示图例
        break;
      }
    }
    //是否显示图例
    let bool = false;
    for(let i=0;i<showHideArray.length;i++){
      if(showHideArray[i].show){
        bool = true;
        break;
      }
    }
    showHideLegendDivBool.value = bool;
  }else{//清空图例
    //是否显示图例
    for(let i=0;i<showHideArray.length;i++){
      showHideArray[i].show = false;
    }
    showHideLegendDivBool.value = false;
  }
}

// 更多信息
const handleMore = () =>{
  let row = currentRow.value;
  if(row){
    // proxy.$refs['versionCodeTable'].toggleRowExpansion(row);
    //根据版本号查询文件和附件列表
    getFileMessage(row.versionCode).then((response) => {
      nextTick(() => {
        console.log("根据版本号查询文件和附件列表");
        console.log(response.data);
        let result = response.data;
        currentRow.value.dataFileList = result.dataFileList;//文件
        currentRow.value.attachmentFileList = result.attachmentFileList;//附件
        openMore.value = true;
      });
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }
}
//元数据管理
const openDetail = () => {
  let row = currentRow.value;
  if(row){
    if(row.versionCode){
      isEdit.value = false;
      isFirstOpen.value = false;
      handleDetail(row.versionCode)
    }
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }
}
//删除
const handleDelete = () => {
  /*let row = currentRow.value;
  if(row){
    let id = row.id;
    let message = "版本号：" + row.versionCode + "，是否确定删除？";
    proxy.$modal.confirm(message, 'Warning',
        {
          confirmButtonText: '删除',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(function () {
      //取消选中当前行
      clickRow(row);
      //删除
      return delAdministrativeArea(id);
    }).then(() => {
      //查询版本列表
      radioChange();
      proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {
      proxy.$modal.msgWarning("删除失败");
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }*/
  //批量删除勾选版本数据
  let dataList = versionCodeTableData.value;
  let list = selectdatas.value;
  if(list!=null && list.length>0){
    let ids = "";
    let versions = "";
    for(let i=0;i<list.length;i++){
      if(i>0){
        ids += ",";
        versions += "、";
      }
      for(let j=0;j<dataList.length;j++){
        if(dataList[j].versionCode==list[i]){
          ids += dataList[j].id;
          versions += dataList[j].versionCode;
          break;
        }
      }
    }
    let message = "版本号：" + versions + "，是否确定批量删除？";
    proxy.$modal.confirm(message, 'Warning',
        {
          confirmButtonText: '删除',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(function () {
      //批量删除
      return delByIds(ids);
    }).then(() => {
      //重置数据图层
      resetCollapseDiv();
      proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {
      
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }
}

// 编辑元数据
function submitFormYuan() {
  proxy.$refs["ruleFormData"].validate(valid => {
    if (valid) {
      updateAdministrativeArea({ ...formData.value }).then(res => {
        // getList();
        proxy.$modal.msgSuccess("保存成功");
        openData.value = false;
      })
    }
  });
}

// 数据详情
function handleDetail(versionCode) {
  getDetail(versionCode).then(res => {
    formData.value = {
      dataScope: '1',
      type: '1',
      ...res.data,
    };
    const {dataRangeProvince, dataRangeCity, dataRangeCountry} = formData.value;
    editProvinceFormData(dataRangeProvince, dataRangeCity, dataRangeCountry)
  })
}

function editProvinceFormData(provinceId, cityId,countyId) {
  if (!provinceId && !cityId) {
    cityFormData1.value = [];
    areaFormData1.value = [];
  }

  if (provinceId) {
     getProvince().then(response => {
      provinceFormData1.value = response.data;
    });
  }
  if(cityId){
    getChildArea(provinceId).then(response => {
      cityFormData1.value = response.data;
    });
  }
  if(countyId){
    getChildArea(cityId).then(response => {
      areaFormData1.value = response.data;
    });
  }
  openData.value = true;
  proxy.resetForm("ruleFormData");
}

// 下载文件
function handleDownload(row) {
  var query = {
    attachId: row.attachId,
    attachName: row.attachName
  }
  location.href = import.meta.env.VITE_APP_BASE_API + "/attachment/downLoadTifFile?attachId=" + encodeURIComponent(query.attachId);
}

//根据高程文件ID获取tif文件地址
const findTifFilePathById = (versionCode,id)=>{
  if(id){
    findOneById(id).then((response) => {
      nextTick(() => {
        console.log("获取文件详情");
        console.log(response.data);
        let result = response.data;
        if(result && result.fileDirId && result.attachPath){
          // attachPath: "\\tif\\/2023/05/05/坐标转换后的四川dem90米_1683254637249.tif"
          // fileDirId: "D:\\static"
          let fileDirId = result.fileDirId;
          let attachPath = result.attachPath;
          // attachPath = attachPath.replaceAll("\\/","\\");
          // attachPath = attachPath.replaceAll("/","\\");
          let filePath = fileDirId + attachPath;
          // filePath = "D:\\static\\tif\\2023\\05\\05\\坐标转换后的四川dem90米_1683254637249.tif";
          //当前tif文件路径
          currentTifFilePath.value = filePath;
          //当前tif文件信息
          currentTifAttach.value = result;
          console.log(filePath);
          let attachName = result.attachName;
          let tifFileName = attachName.split(".")[0];
          let radioLabel = activeRadioLabel.value;
          allListData.value = [radioLabel,versionCode,[],true,tifFileName];//显示超图图层
        }
      });
    });
  }
}

//根据文件ID获取tif文件信息
const getAttachFileDataById = (versionCode,id,dataType,dataLength)=>{
  if(id){
    getAttachById(id).then((response) => {
      nextTick(() => {
        console.log("获取tif文件详情");
        console.log(response.data);
        let result = response.data;
        if(result && result.fileDirId && result.attachPath){
          let fileDirId = result.fileDirId;
          let attachPath = result.attachPath;
          // attachPath = attachPath.replaceAll("\\/","\\");
          // attachPath = attachPath.replaceAll("/","\\");
          let filePath = fileDirId + attachPath;
          console.log(filePath);
          //当前tif文件路径
          currentTifFilePath.value = filePath;
          //当前tif文件信息
          currentTifAttach.value = result;
          loading.value = false;
          if(dataType){//生成坡度坡向
            //文件数据长度
            result.dataLength = dataLength;
            //数据类型
            addDataType.value = dataType;
            handleAdd();//添加数据
            // proxy.$modal.msgSuccess("生成成功");
            let attachName = result.attachName;
            let tifFileName = attachName.split(".")[0];
            console.log("发布tif图层名称："+tifFileName);
          }else{//坡度坡向查询
            let attachName = result.attachName;
            let tifFileName = attachName.split(".")[0];
            let radioLabel = activeRadioLabel.value;
            allListData.value = [radioLabel,versionCode,[],true,tifFileName];//显示超图图层
          }
        }
      });
    });
  }
}

//计算坡度
const computeSaveSlopeTif = ()=>{
  let row = currentRow.value;
  let typeCode = currentLayerCode.value;
  if(typeCode=="dxdmpd" || typeCode=="dxdmpx"){
    proxy.$modal.msgWarning("请先勾选1条高程数据");
    return;
  }
  //当前高程数据的文件路径
  let demTifFilePath = currentTifFilePath.value;
  if(row && demTifFilePath){
    let message = "版本号：" + row.versionCode + "，是否确定生成坡度？";
    proxy.$modal.confirm(message, 'Warning',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(function () {

      loading.value = true;
      let params = {
        demTifFilePath:demTifFilePath
      }
      //计算坡度
      computeSlopeTif(params).then((response) => {
        nextTick(() => {
          console.log("计算坡度");
          console.log(response.data);
          let result = response.data;
          let msg = result[0];
          if(msg=="生成成功"){
            let attachId = result[1];
            let dataLength = result[2];
            //根据文件ID获取tif文件信息
            getAttachFileDataById(row.versionCode,attachId,"dxdmpd",dataLength);
          }else{
            loading.value = false;
            proxy.$modal.msgWarning(msg);
          }
        });
      }).catch(err => {
        loading.value = false;
        proxy.$modal.msgWarning("生成失败");
      });
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条高程数据");
  }
}
const uploadAspectTif = () => {
  
}
const uploadType = ref('')
const uploadSlopeTifAspectTif = (type) => {
  uploadType.value = type
  openUpload.value = true
}
//计算坡向
const computeSaveAspectTif = ()=>{
  let row = currentRow.value;
  let typeCode = currentLayerCode.value;
  if(typeCode=="dxdmpd" || typeCode=="dxdmpx"){
    proxy.$modal.msgWarning("请先勾选1条高程数据");
    return;
  }
  //当前高程数据的文件路径
  let demTifFilePath = currentTifFilePath.value;
  if(row && demTifFilePath){
    let message = "版本号：" + row.versionCode + "，是否确定生成坡向？";
    proxy.$modal.confirm(message, 'Warning',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(function () {

      loading.value = true;
      let params = {
        demTifFilePath:demTifFilePath
      }
      //计算坡向
      computeAspectTif(params).then((response) => {
        nextTick(() => {
          console.log("计算坡向");
          console.log(response.data);
          let result = response.data;
          let msg = result[0];
          if(msg=="生成成功"){
            let attachId = result[1];
            let dataLength = result[2];
            //根据文件ID获取tif文件信息
            getAttachFileDataById(row.versionCode,attachId,"dxdmpx",dataLength);
          }else{
            loading.value = false;
            proxy.$modal.msgWarning(msg);
          }
        });
      }).catch(err => {
        loading.value = false;
        proxy.$modal.msgWarning("生成失败");
      });
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }
}

//坡度分区统计
const countDivisionalSlopeTif = ()=>{
  let row = currentRow.value;
  //当前坡度数据的文件路径
  let tifFilePath = currentTifFilePath.value;
  console.log("坡度分区统计");
  console.log(row);
  console.log(tifFilePath);
  if(row && tifFilePath){
    let message = "版本号：" + row.versionCode + "，是否确定进行坡度分区统计？";
    proxy.$modal.confirm(message, 'Warning',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(function () {

      loading.value = true;
      //读取坡度tif文件进行坡度分区统计（网格数、面积、占比）
      countSlopeTif(tifFilePath).then((response) => {
        nextTick(() => {
          console.log("坡度分区统计结果");
          console.log(response.data);
          let result = response.data;
          let msg = result[0];
          if(msg=="统计成功"){
            let countString = result[1];
            let countList = countString.split(",");
            let areaString = result[2];
            let areaList = areaString.split(",");
            let dataLength = Number(countList[0]);
            let nameList = ["全部","<=10","(10,20]","(20,30]","(30,40]","(40,50]","(50,60]","(60,70]","(70,80]","(80,90]"];
            let list = [];
            for(let i=1;i<countList.length;i++){
              let count = Number(countList[i]);
              let area = Number(areaList[i]).toFixed(4);//保留4位小数
              let percent = (count / dataLength * 100).toFixed(2);//保留2位小数
              let obj = {
                division:nameList[i],
                count:count,
                area:area,
                percent:percent
              }
              list.push(obj);
            }
            //图层表格数据列表
            allTableDataList.value = list;
            //表头字段列表
            allTableTitleList.value = [
              {prop:"division",label:"坡度分区"},
              {prop:"count",label:"网格数（个）"},
              {prop:"area",label:"面积（平方公里）"},
              {prop:"percent",label:"占比（%）"}
            ];
            total.value = 9;//总数据量
            allTableDataBool.value = true;//显示表格
            queryTableDataByPageBool.value = false;//不分页查询数据
            loading.value = false;
          }else{
            loading.value = false;
            proxy.$modal.msgWarning(msg);
          }
        });
      }).catch(err => {
        loading.value = false;
        proxy.$modal.msgWarning("统计失败");
      });
    });
  }else{
    proxy.$modal.msgWarning("请先勾选1条数据");
  }
}

//生成图件
const showImgcreateBool = ref(false);
const showImgcreate = (val) =>{
  showImgcreateBool.value = val;
}
//关闭生成图件窗口
const closeImgDialog = (bool)=>{
  showImgcreateBool.value = false;
}
//获取全部图层信息列表
const getAllTempLayersSetList = (obj)=>{
  console.log("getAllTempLayersSetList");
  console.log(obj);
  if(obj){
    let list = obj.list;
    if(list && list.length>0){
      printParams.value.geomText = obj.geomText;//图件空间范围数据
      printParams.value.tempLayersSetList = list;//图层（临时图层）url列表--用于显示图层
      printParams.value.legendSetList = list;//图层（临时图层）url列表--用于显示图例
    }
  }
}

//获取数据类型一级
const getLevel1DataType = watch(() => props.dataType, value => {// watch函数监听props.dataType
  if(value){
    getAllTreeData(value);
  }
},{immediate:true});


onMounted(async() => {
  await admin();
  await getProvinceData();
  await setLayerShowHideArray();
  await alertSelect();
  setTimeout(()=>{
    isAdminCountryId1();
  },500);
})
</script>

<style scoped lang="scss">
.mapDiv {
  position:absolute;top:0px;left:0px;width:100%;height:100%;
}
.select{
  position:absolute;
  top:29px;
  left:29px;
  width: 300px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .selectData{
    color: darkolivegreen;
    width: 150px;
    height: 40px;
    box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
    /*border:1px solid #707070;*/
    padding: 0px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-radius: 4px;
  }
}

.box {
  position:absolute;
  top:70px;
  left:29px;
  width: 400px;
  bottom:17px;
  background-color: #fff;
  transition: height 0.3s ease;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
}

.box-max {
  width: 820px;
}

.box-min {
  width: 400px;
}

.box-hide-div {
  position:absolute;
  top:80px;
  left:29px;
  width:370px;
  height:130px;
  color:#fff;
  background: #000;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
  border:1px solid #707070;
  border-radius: 4px;
  opacity: 0.5;
}

.box-hide-div-label-span {
  position: absolute;top:10px;left:15px;font-weight: bold;font-size: 16px;
}

.box-hide-div-text-span {
  position: absolute;
  top: 40px;
  left: 15px;
  font-size: 14px;
  height: 80px;
  overflow: auto;
  right: 15px;
}

.tab-div {
  position:absolute;top:0px;left:0px;width:110px;height: 100%;border-right: 1px solid #d8dce5;
}
.tab-button {
  position:relative;top:0px;left:0px;width:100%;height:50px;line-height: 50px;text-align: center;
}
.tab-active {
  color:#fff;
  background:#107ce5;
}
.tab-no {
  color:#666;
  background:#fff;
}

.tab-content-all-div {
  position:absolute;top:0px;left:110px;width:290px;height: 100%;
}

.tab-content {
  position:absolute;top:0px;left:0px;width:100%;height:100%;
}

.tab-span {
  float: right;margin:10px;color: #107ce5;cursor: pointer;font-size: 14px;
}

.tab-layercollapse-allShow {
  position: absolute;top: 80px;width:100%;bottom:0px;
}

.tab-layercollapse-allShow-head {
  width:100%;height:40px;background:#fff;
}

.tab-layercollapse-allHide {
  width:100%;background:rgb(230 242 253);min-height: 80px;max-height:200px;border-top: 1px solid #d8dce5;overflow:auto;
}

.tab-layercollapse-allHide-label-span{
  position: relative;top:10px;left:20px;font-weight: bold;font-size: 16px;
}
.tab-layercollapse-allHide-text-span {
  position: relative;margin-top: 20px;left:20px;font-size: 14px;width: 250px;display: block;
}

.tab-layercollapse-div{
  position: absolute;top: 40px;width:100%;bottom:0px;overflow:auto;
}

.foot-div {
  position:absolute;left:0px;bottom:0px;width:400px;height:40px;border-top:1px solid #d8dce5;cursor: pointer;
}

.tab-select-versionCode-div {
  position: absolute;top:0px;left:400px;width:420px;bottom:0px;background:#fff;
  border-left:1px solid #d8dce5;padding:10px;
}

.tab-collapse-radioDiv{
  padding-left:20px;
}

.tab-table-div {
  position:absolute;top:102px;left:0px;width:100%;bottom: 40px;overflow: auto;
}

:deep(.el-collapse-item__header) {
  background-color: rgb(230 242 253) !important;
  padding-left: 10px;
  font-size: 14px;
  color: #475767;
}

:deep(.el-collapse-item__content) {
  padding-top: 20px;
  padding-bottom: 20px;
}

// 深度选择器 去掉表头全选按钮
:deep(.el-table__header-wrapper .el-checkbox) {
  display: none;
}

//图例
.layerMap-legend {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 50px;
  background: #fff;
  padding: 10px;
  overflow: auto;
  min-width: 200px;
  box-shadow: 0px 0px 20px rgba(0,0,0,0.2);
  border:1px solid #707070;
  border-radius: 4px;
}
.layerMap-legend p:first-child{
  text-align: center;font-weight: bold;
}

.computeDiv {
  position: absolute;
  top: 29px;
  left: 430px;
}

.countDiv {
  position: absolute;
  top: 29px;
  left: 430px;
}

.table-button-div {
  position: absolute;
  bottom: 0px;
  height: 40px;
  padding: 5px;
}

.expandTable {
  padding: 5px 20px 5px 20px;

  h3 {
    font-weight: bold;
  }

  p {
    margin: 0px;
    line-height: 25px !important;
  }
}

.tab-title {
  font-size: 16px;
  font-weight: bold;
  border-left: 4px solid #0D9AFF;
  font-family: PingFangSC-Medium;
  padding-left: 10px;
  margin-bottom: 20px;
}

.tab-more{
  font-size: 16px;
  font-weight: bold;
  border-left: 3px solid #000000;
  font-family: PingFangSC-Medium;
  padding-left: 10px;
  margin-bottom: 20px;
}
.sub-tit{
  font-size: 14px;
  color: #707070;
  margin-bottom: 20px;
  margin-right: 10px;
  display: inline-block;
  font-weight: 600;
}
.uploadDialog {
  text-align: center;
  .close {
    text-align: right;

    .el-icon {
      color: #606266;
      padding: 20px 0;
      margin-right: 10px;
      right: 0px;
      font-size: 22px;
    }
  }
  width: 320px;
  position: absolute;
  top: 11%;
  right: 12%;
  background: rgba($color: #fff, $alpha: 0.9);
}
</style>